package com.one.service.impl;

import com.one.mapper.OneSuperMapper;
import com.one.mapper.StoreMapper;
import com.one.pojo.OneSuper;
import com.one.pojo.Store;
import com.one.service.OneSuperService;
import com.one.util.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Description
 * @Author semstouch
 * @Date 2017/4/8
 **/
@Service
public class OneSuperServiceImpl implements OneSuperService{
    @Resource
    private OneSuperMapper oneSuperMapper;
    @Resource
    private StoreMapper storeMapper;

    @Override
    public OneSuper update(OneSuper oneSuper,Store store) {
        oneSuperMapper.updateByPrimaryKeySelective(oneSuper);
        if(store!=null) {
            storeMapper.updateByPrimaryKeySelective(store);
        }
        return oneSuper;
    }

    @Override
    public OneSuper find(String userId) {
        return oneSuperMapper.selectByUserId(userId);
    }

    @Override
    public OneSuper add(OneSuper oneSuper,Store store) {
        oneSuper.setId(StringUtils.getUUID());
        oneSuperMapper.insertSelective(oneSuper);
        return oneSuper;
    }
}
